package com.example.owner.lettery1.modlus

import com.example.owner.lettery1.bean.LotteryBean
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers


class LotteryPresenter {

    fun getLottoredBeans(): Observable<ArrayList<LotteryBean>> {
        val api = RetrofitClient.createService(NewsApi::class.java)
        val callback = api.getLotteryList("1")
        return callback.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .map { data ->
                    if (data.datas != null || data.datas!!.isNotEmpty()) {
                        return@map data.datas!!
                    }
                    return@map ArrayList<LotteryBean>()
                }
    }
}